package drone.iqgc.common ;

import com.alibaba.fastjson.JSONArray ;
import com.alibaba.fastjson.JSONObject ;

import drone.basis.util.StringUtil ;

public class Message
{

	public static String generate (
			String code ,
			String msg ,
			String type ,
			String name ,
			String target ,
			JSONObject data
	)
	{

		JSONObject message = new JSONObject ( ) ;
		message.put ( "id" , StringUtil.guid ( ) ) ;
		message.put ( "code" , code ) ;
		message.put ( "msg" , msg ) ;
		message.put ( "type" , type ) ;
		message.put ( "name" , name ) ;
		message.put ( "target" , target ) ;
		message.put ( "data" , data ) ;

		return message.toJSONString ( ) ;

	}

	public static String generate (
			String code ,
			String msg ,
			String type ,
			String name ,
			String target ,
			JSONArray data
	)
	{

		JSONObject message = new JSONObject ( ) ;
		message.put ( "id" , StringUtil.guid ( ) ) ;
		message.put ( "code" , code ) ;
		message.put ( "msg" , msg ) ;
		message.put ( "type" , type ) ;
		message.put ( "name" , name ) ;
		message.put ( "target" , target ) ;
		message.put ( "data" , data ) ;

		return message.toJSONString ( ) ;

	}

}
